import os
import sys

from script.server.Servers import Servers
from script.SyncFromTelewebToFtp import SyncFromTelewebToFtp
from script.util.FileLog import FileLog
from script.util.Print import Print


DST_ROOT_DIR = '/image-tct'
SYNC_LIST = (
    ('/T2-A1S', '%s/T2-A1S' % DST_ROOT_DIR),
    ('/T2-C2', '%s/T2-C2' % DST_ROOT_DIR),
    ('/T2-D01', '%s/T2-D01' % DST_ROOT_DIR),
    ('/T2-M01', '%s/T2-M01' % DST_ROOT_DIR),
    ('/T2-PM45-O', '%s/T2-PM45-O' % DST_ROOT_DIR),
    ('/T2-PM45-P', '%s/T2-PM45-P' % DST_ROOT_DIR),
    ('/T2-PM85', '%s/T2-PM85' % DST_ROOT_DIR),
    ('/T2-PM85-P', '%s/T2-PM85-P' % DST_ROOT_DIR),
    ('/T2-PM85-W', '%s/T2-PM85-W' % DST_ROOT_DIR),
    ('/T2-PM85W-P', '%s/T2-PM85W-P' % DST_ROOT_DIR),
    ('/T2-PM90', '%s/T2-PM45' % DST_ROOT_DIR),
    ('/T2-VIVA', '%s/T2-VIVA' % DST_ROOT_DIR),
    ('/T2M-C7', '%s/T2M-C7' % DST_ROOT_DIR),
    ('/T2M-DTX450', '%s/T2M-DTX450' % DST_ROOT_DIR),
    ('/T2M-FairPhone4', '%s/T2M-FairPhone4' % DST_ROOT_DIR),
    ('/T2M-PM30', '%s/T2M-PM30' % DST_ROOT_DIR),
    ('/T2M-PM90R', '%s/T2M-PM90R' % DST_ROOT_DIR),
    ('/T2M-RS35R', '%s/T2M-RS35R' % DST_ROOT_DIR),
    ('/T2M-RS51', '%s/T2M-RS51' % DST_ROOT_DIR),
    ('/T2M-VERNUS', '%s/T2M-VENUS' % DST_ROOT_DIR)
)


def main():
    if len(sys.argv) > 1:
        if sys.argv[1] == '--disable-color':
            Print.enable_color(False)  # disable color

    log = FileLog(os.path.join(os.path.dirname(sys.argv[0]), 'log'))
    for sync_info in SYNC_LIST:
        SyncFromTelewebToFtp(Servers.SERVER_TCLNB, sync_info[0],
                             Servers.SERVER_T2MNB, sync_info[1],
                             None).sync_all().close()


if __name__ == '__main__':
    main()
